<template>
    <div class="newPrimaryClass">
        <div class="newPrimaryClass_top">
			<div class="into_index">首页<i class="el-icon-close"></i></div>
			<div class="current">{{text}}<i class="el-icon-close"></i></div>
		</div>
        <!-- 商家类型与返回 -->
        <div class="newPrimaryClass_type">
            <div>待处理/<span class="text">{{text}}</span></div>
            <el-button @click="toBack" type="success">返回</el-button>
        </div>

        <!-- 基础信息 -->
        <div class="contentBox">
            <h3>基础信息</h3>
            <div class="boxBig">
                <div class="item">
                    <div class="tit">业主姓名</div>
                    <el-input style="width:40%;" placeholder="请输入业主姓名" class="input" type="text" v-model="form.realname"></el-input>
                </div>
                <div class="item">
                    <span class="tit">手机号码</span>
                    <el-input style="width:40%;" placeholder="请输入手机号码" class="input" type="number" v-model="form.phone"></el-input>
                </div>
            </div>
            <div class="boxBig">
                <div class="item">
                    <div class="tit">户型</div>
                    <el-input style="width:40%;" placeholder="请输入户型" class="input" type="text" v-model="form.house_type"></el-input>
                </div>
                <div class="item">
                    <span class="tit">面积</span>
                    <el-input style="width:40%;" placeholder="请输入面积" class="input" type="number" v-model="form.house_area"></el-input>m²
                </div>
            </div>
            <div class="boxBig">
                <div class="item">
                    <div class="tit">小区</div>
                    <el-input style="width:40%;" placeholder="请输入小区" class="input" type="text" v-model="form.estate"></el-input>
                </div>
            </div>
            <div class="item">
				<div class="tit">施工地址</div>
				<el-select v-model="provinceObj" @change="select1" value-key="cityid" placeholder="请选择省份">
					<el-option
					v-for="item in province"
					:key="item.cityid"
					:label="item.city_name"
					:value="{cityid:item.cityid,city_name:item.city_name}">
					</el-option>
				</el-select>
				<el-select v-model="cityObj" @change="select2" value-key="cityid" placeholder="请选择城市">
					<el-option
					v-for="item in city"
					:key="item.cityid"
					:label="item.city_name"
					:value="{cityid:item.cityid,city_name:item.city_name}">
					</el-option>
				</el-select>
				<el-select v-model="districtObj" @change="select3" value-key="cityid" placeholder="请选择县区">
					<el-option
					v-for="item in district"
					:key="item.cityid"
					:label="item.city_name"
					:value="{cityid:item.cityid,city_name:item.city_name}">
					</el-option>
				</el-select>
				<el-select v-model="streetObj" @change="select4" value-key="cityid" placeholder="请选择街道">
					<el-option
					v-for="item in street"
					:key="item.cityid"
					:label="item.city_name"
					:value="{cityid:item.cityid,city_name:item.city_name}">
					</el-option>
				</el-select>
                <el-input style="width:27%;" v-model="form.address" placeholder="请输入楼盘详细地址"></el-input>
			</div>
			<div class="item">
				<div class="tit">施工诉求</div>
				<el-input type="textarea" v-model="form.remark" style="width:70%" rows="4"></el-input>
			</div>
        </div>
		<!-- 基础信息 -->
        <div class="contentBox">
            <h3>施工信息</h3>
            <!-- <div class="boxBig">
                <div class="item">
                    <div class="tit">管家</div>
                    <div class="position">
						<el-input type="text" v-model="house_keeper.name" placeholder="请选择"></el-input>
						<el-input type="number" v-model="house_keeper.phone" placeholder=""></el-input>
						<el-button type="primary" @click="selectKeeper">选择</el-button>
					</div>
                </div>
                <div class="item">
                    <span class="tit">工长</span>
                    <div class="position">
						<el-input type="text" v-model="foreman.name" placeholder="请选择"></el-input>
						<el-input type="number" v-model="foreman.phone" placeholder=""></el-input>
						<el-button type="primary" @click="selectForeman">选择</el-button>
					</div>
                </div>
            </div> -->
			<div class="item">
				<div class="tit">施工时间</div>
				<el-date-picker
					v-model="constrTime"
					type="daterange"
					range-separator="至"
					start-placeholder="开始日期"
					end-placeholder="结束日期">
				</el-date-picker>
			</div>
			<div class="item">
				<div class="tit">施工合同</div>
				<!-- <el-input class="itemIpt" type="file"></el-input> -->
                <el-upload
                    action="/api/client/base/uploadfile"
                    list-type="picture-card"
                    :on-success="handleEstateSuccess1"
                    :on-preview="handlePictureCardPreview1"
                    :headers="myHeaders"
                    :file-list="fileList1"     
                    :before-upload="beforeAvatarUpload1"         
                    :limit="10" 
                    :auto-upload="true"
                    :on-remove="handleRemove1">
                    <i class="el-icon-plus"></i>
                </el-upload>
                <el-dialog :visible.sync="dialogVisible1">
                    <img width="100%" :src="dialogImageUrl1" alt="">
                </el-dialog>
			</div>
			<div class="item">
				<div class="tit">施工图纸</div>
                <el-upload
                    action="/api/client/base/uploadfile"
                    list-type="picture-card"
                    :on-success="handleEstateSuccess"
                    :on-preview="handlePictureCardPreview"
                    :headers="myHeaders"
                    :file-list="fileList"     
                    :before-upload="beforeAvatarUpload"         
                    :limit="10" 
                    :auto-upload="true"
                    :on-remove="handleRemove">
                    <i class="el-icon-plus"></i>
                </el-upload>
                <el-dialog :visible.sync="dialogVisible">
                    <img width="100%" :src="dialogImageUrl" alt="">
                </el-dialog>
			</div>
			<div class="item" v-if="form.decoration_id">
				<div class="tit">设计图纸</div>
                <el-upload
                    action="/api/client/base/uploadfile"
                    list-type="picture-card"
                    :on-success="handleEstateSuccess_desgin"
                    :on-preview="handlePictureCardPreview_desgin"
                    :headers="myHeaders"
                    :file-list="fileList_desgin"     
                    :before-upload="beforeAvatarUpload_desgin"         
                    :limit="10" 
                    :auto-upload="true"
                    :on-remove="handleRemove_desgin">
                    <i class="el-icon-plus"></i>
                </el-upload>
                <el-dialog :visible.sync="dialogVisible_desgin">
                    <img width="100%" :src="dialogImageUrl_desgin" alt="">
                </el-dialog>
			</div>
			<div class="item">
				<div class="tit">选材单</div>
                <el-upload
                    action="/api/client/base/uploadfile"
                    list-type="picture-card"
                    :on-success="handleEstateSuccess_mater"
                    :on-preview="handlePictureCardPreview_mater"
                    :headers="myHeaders"
                    :file-list="fileList_mater"     
                    :before-upload="beforeAvatarUpload_mater"         
                    :limit="10" 
                    :auto-upload="true"
                    :on-remove="handleRemove_mater">
                    <i class="el-icon-plus"></i>
                </el-upload>
                <el-dialog :visible.sync="dialogVisible_mater">
                    <img width="100%" :src="dialogImageUrl_mater" alt="">
                </el-dialog>
			</div>
            <div class="boxBig priceBox">
                <div class="item">
                    <div class="tit">合同金额</div>
                    <el-input class="itemIpt" v-model="form.contract_price" type="number"></el-input>元
                </div>
                <!-- <div class="item" v-if="form.is_many_way==1">
                    <div class="tit">已收定金</div>
                    <el-input class="itemIpt" v-model="form.deposit_price" type="number"></el-input>元
                </div>
                <div class="item" v-if="form.is_many_way==1">
                    <div class="tit">待付尾款</div>
                    <el-input class="itemIpt" v-model="form.balance_price" type="number"></el-input>元
                </div> -->
                <div class="item">
                    <div class="tit">支付次数</div>
                    <el-input class="itemIpt" readonly :value="form.pay_progress?form.pay_progress.length:''" type="number"></el-input>
                </div>
                <div class="item">
                    <div class="tit">支付比例</div>
                    <el-input class="itemIpt" readonly :value="form.pay_rule?form.pay_rule.replace(/,/g,'、'):''" type="text"></el-input>
                </div>
                <div class="progressBox">
                    <div class="item" v-for="(item,index) in form.pay_progress" :key="index">
                        <div class="left">
                            <span>{{index+1}}</span>
                            {{item.rate*100}}%
                            <div class="price">(￥{{item.amount}})</div>
                        </div>
                        <div class="rightBtn" v-if="item.checked || item.pay_status!=0" @click="toCollect(item.id,item.pay_status)" :class="{'activeBtn':item.checked&&item.pay_status==0}">{{item.pay_status==0?'发起收款':item.pay_status==1?'待付款':'已付款'}}</div>
                    </div>
                </div>
                <div class="remarksBox">
                备注
                <el-input
                    type="textarea"
                    style="width:500px;margin-left:20px;"
                    :rows="4"
                    placeholder="请输入备注"
                    v-model="form.pay_rule_desc">
                </el-input>
                </div>
            </div>
        </div>

        <!-- 其他 -->
        <div class="otherBox">
            <el-tabs v-model="activeName" @tab-click="handleClick" >
                <el-tab-pane label="负责人" name="1">
                    <div class="positionItem">
                        <div class="tit">管家</div>
                        <el-input v-model="house_keeper.name" readonly type="text"></el-input>
                        <el-input v-model="house_keeper.phone" readonly type="number"></el-input>
                        <el-button type="primary" @click="selectKeeper">更换</el-button>
                    </div>
                    <div class="positionItem">
                        <div class="tit">工长</div>
                        <el-input v-model="foreman.name" readonly type="text"></el-input>
                        <el-input v-model="foreman.phone" readonly type="number"></el-input>
                        <el-button type="primary" @click="selectForeman">更换</el-button>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="施工进度" name="2">
                     <el-table
                        :data="progressData"
                        style="width: 100%">
                        <el-table-column
                            align="center"
                            prop="id"
                            label="序号">
                        </el-table-column>
                        <el-table-column
                            align="center"
                            prop="name"
                            label="节点目标">
                        </el-table-column>
                        <el-table-column
                            align="center"
                            prop="complete_time"
                            :formatter="completeTimeFn"
                            label="施工完成时间">
                        </el-table-column>
                        <el-table-column
                            align="center"
                            prop="status"
                            :formatter="progressStatus"
                            label="进度">
                        </el-table-column>
                        <el-table-column
                            align="center"
                            prop="address"
                            label="操作">
                            <template slot-scope="scope">
                                <el-button size="small" :disabled="scope.row.status!=0" style="width:80px;" :type="scope.row.status==0?'warning':scope.row.status==1?'danger':'success'" @click="toConfirm(scope.$index, scope.row)">{{scope.row.status==0?'未完工':scope.row.status==1?'待确认':'已完工'}}</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <!-- <div class="block">
                        <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="page"
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="pagesize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total">
                        </el-pagination>
                    </div> -->
                </el-tab-pane>
                <el-tab-pane label="施工播报" name="3">
                    <div class="addBroad"><el-button type="success" @click="toAddBroad">添加播报</el-button></div>
                    <ul class="broadList">
                        <li class="item" v-for="(item,index) in broadListData" :key="index">
                            <div class="lef">{{$moment(item.create_time*1000).format('YYYY/MM/DD')}}</div>
                            <div class="right">
                                <div class="text">{{item.title}}<div><i class="el-icon-delete-solid" @click="delBroad(item.id)"></i><i class="el-icon-edit" @click="editBroad(item.id)"></i></div></div>
                                <div class="imgBox" v-if="item.type==0">
                                    <!-- <img :src="item1.path" alt="" v-for="(item1,index1) in item.media" :key="index1"> -->
                                    <el-image :src="item1.path" :preview-src-list="broadImgList" v-for="(item1,index1) in item.media" :key="index1"></el-image>
                                </div>
                                <div class="imgBox" v-else>
                                    <video :src="item1.path" controls :poster="item1.cover" v-for="(item1,index1) in item.media" :key="index1"></video>
                                </div>
                            </div>
                        </li>
                    </ul>
                </el-tab-pane>
                <el-tab-pane label="档案留存" name="4">
                    <div class="addBroad"><el-button type="success" @click="toAddArchive">添加</el-button></div>
                    <el-collapse accordion v-model="activeColl" @change="changeCollapse">
                        <el-collapse-item v-for="(item,index) in archivesList" :key="index" :name="item.id">
                            <template slot="title">
                                <h3 class="title_box">{{item.name}}</h3>
                                <div class="iconBox">
                                    <i class="el-icon-delete-solid" @click.stop="delArchive(item.id)"></i>
                                    <i class="el-icon-edit" @click.stop="editArchive(item.name,item.id)"></i>
                                    <i class="el-icon-circle-plus-outline" @click.stop="addReta(item.id)"></i>
                                </div>
                            </template>
                            <ul class="catalogue">
                                <li class="cataItem" v-for="(item1,index1) in retaList" :key="index1">
                                    <div class="itemTit">
                                        <h4>{{item1.title}}</h4>
                                        <div class="iconBox">
                                            <i class="el-icon-delete-solid" @click.stop="delReta(item.id,item1.id)"></i>
                                            <i class="el-icon-edit" @click.stop="editReta(item.id,item1.id)"></i>
                                        </div>
                                    </div>
                                    <div>{{item1.content}}</div>
                                    <div class="imgBox" v-if="item1.type==0">
                                        <template v-if="Array.isArray(item1.media)">
                                            <el-image :src="item2.path" :preview-src-list="retaImgList" v-for="(item2,index2) in item1.media" :key="index2"></el-image>
                                            <!-- <img :src="item2.path" alt="" v-for="(item2,index2) in item1.media" :key="index2"> -->
                                        </template>
                                        <template v-else>
                                            <el-image :src="item1.media.path" :preview-src-list="retaImgList"></el-image>
                                            <!-- <img :src="item1.media.path" alt=""> -->
                                        </template>
                                    </div>
                                    <div class="imgBox" v-else>
                                        <template v-if="Array.isArray(item1.media)">
                                            <video :src="item2.path" alt="" controls :poster="item2.cover" v-for="(item2,index2) in item1.media" :key="index2"></video>
                                        </template>
                                        <template v-else>
                                            <video :src="item1.media.path" controls :poster="item1.media.cover" ></video>
                                        </template>
                                    </div>
                                </li>
                            </ul>
                        </el-collapse-item>
                    </el-collapse>
                </el-tab-pane>
            </el-tabs>
        </div>


        <div class="btn">
            <el-button type="primary" @click="toSubmit">提交</el-button>
        </div>

        <!-- 成员列表弹出选择 -->
		<el-dialog title="职位选择" :visible.sync="dialogTableVisible">
			<el-table :data="personList">
				<el-table-column property="name" label="姓名" width="200"></el-table-column>
				<el-table-column property="phone" label="手机号" width="200"></el-table-column>
				<el-table-column label="操作">
					<template slot-scope="scope">
						<el-button type="primary" size="mini" @click="toSelect(scope.$index, scope.row)">选择</el-button>
					</template>
				</el-table-column>
			</el-table>
		</el-dialog>

        <!-- 添加播报 -->
        <el-dialog
            title="施工播报"
            :visible.sync="dialogVisible_broad"
            @closed="closedFn"
            width="40%">
            <div class="broadBox">
                <el-form>
                    <el-form-item label="类型">
                        <el-radio v-model="radioBroad" :disabled="radio_broad" label="0">图文</el-radio>
                        <el-radio v-model="radioBroad" :disabled="radio_broad" label="1">视频</el-radio>
                    </el-form-item>
                    <el-form-item label="播报说明">
                        <el-input style="width:80%;" v-model="broadTitle" type="textarea"></el-input>
                    </el-form-item>
                    <el-form-item label="上传图片" v-if="radioBroad=='0'">
                        <el-upload
                            action="/api/client/base/uploadfile"
                            list-type="picture-card"
                            :on-success="handleBroadSuccess"
                            :on-preview="handleBroadPreview"
                            :headers="myHeaders"
                            :file-list="fileListBroad"     
                            :before-upload="beforeBroadUpload"         
                            :limit="10" 
                            :auto-upload="true"
                            :on-remove="handleBroadRemove">
                            <i class="el-icon-plus"></i>
                        </el-upload>
                        <el-dialog :visible.sync="dialogVisibleBroad">
                            <img width="100%" :src="dialogImageUrlBroad" alt="">
                        </el-dialog>
                    </el-form-item>
                    <el-form-item label="上传视频" v-else>
                        <div class="videoBox">
                            <template v-if="fileBroadVideo.length">
                                <div class="videoItem" v-for="(item,index) in fileBroadVideo" :key="index"> 
                                    <video
                                        :src="item.url"
                                        class="video-avatar"
                                        controls="controls">
                                        您的浏览器不支持视频播放
                                    </video>
                                    <i class="el-icon-circle-close" @click.stop="toDelBroadVideo(index)"></i>
                                </div>
                            </template>
                            <div class="plusBox">
                                <i class="el-icon-plus"></i>
                                <input type="file"
                                accept="video/mp4, video/ogg, video/flv, video/avi, video/wmv, video/rmvb, video/mov"
                                @change="toUploadVideo($event,1)"
                                />
                            </div>
                        </div>
                    </el-form-item>
                </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible_broad = false">取 消</el-button>
                <el-button type="primary" @click="toAddBroadConfirm">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 档案目录 -->
        <el-dialog
            title="档案目录"
            :visible.sync="dialogVisibleArchive"
            @closed="closedArchiveFn"
            width="40%">
            <div class="broadBox">
                <el-form>
                    <el-form-item label="档案名">
                        <el-input style="width:80%;" v-model="archiveTitle" type="text"></el-input>
                    </el-form-item>
                </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisibleArchive = false">取 消</el-button>
                <el-button type="primary" @click="toAddArchiveConfirm">确 定</el-button>
            </span>
        </el-dialog>

        <!-- 档案留存 -->
        <el-dialog
            title="档案留存"
            :visible.sync="dialogVisibleReta"
            @closed="closedRetaFn"
            width="40%">
            <div class="broadBox">
               <el-form>
                    <el-form-item label="类型">
                        <el-radio v-model="radioType" :disabled="radio_reta" label="0">图文</el-radio>
                        <el-radio v-model="radioType" :disabled="radio_reta" label="1">视频</el-radio>
                    </el-form-item>
                    <el-form-item label="标题">
                        <el-input style="width:80%;" v-model="retaTitle" type="text"></el-input>
                    </el-form-item>
                    <el-form-item label="内容">
                        <el-input style="width:80%;" v-model="retaContent" type="textarea"></el-input>
                    </el-form-item>
                    <el-form-item label="图片" v-if="radioType=='0'">
                        <el-upload
                            action="/api/client/base/uploadfile"
                            list-type="picture-card"
                            :on-success="handleRetaSuccess"
                            :on-preview="handleRetaPreview"
                            :headers="myHeaders"
                            :file-list="fileListReta"     
                            :before-upload="beforeRetaUpload"         
                            :limit="10" 
                            :auto-upload="true"
                            :on-remove="handleRetaRemove">
                            <i class="el-icon-plus"></i>
                        </el-upload>
                        <el-dialog :visible.sync="dialogVisibleReta_img">
                            <img width="100%" :src="dialogImageUrlReta" alt="">
                        </el-dialog>
                    </el-form-item>
                    <el-form-item label="视频" v-else>
                        <div class="videoBox">
                            <!-- <el-upload 
                                class="uploadVideo"
                                action="/api/client/base/uploadfile"
                                :on-success="handleRetaVideoSuccess"
                                :headers="myHeaders"
                                :before-upload="beforeRetaVideoUpload"         
                                :limit="1" 
                                :show-file-list="false"
                                :auto-upload="true">
                                <i class="el-icon-plus" v-if="!fileListVideo.length"></i>
                                <video v-if="fileListVideo.length && !videoFlag"
                                    :src="item.response.data.url"
                                    v-for="(item,index) in fileListVideo"
                                    :key="index"
                                    class="video-avatar"
                                    controls="controls">
                                    您的浏览器不支持视频播放
                                </video>
                            </el-upload> -->
                            <template v-if="fileListVideo.length">
                                <div class="videoItem" v-for="(item,index) in fileListVideo" :key="index"> 
                                    <video
                                        :src="item.url"
                                        class="video-avatar"
                                        controls="controls">
                                        您的浏览器不支持视频播放
                                    </video>
                                    <i class="el-icon-circle-close" @click.stop="toDelVideo(index)"></i>
                                </div>
                            </template>
                            <div class="plusBox">
                                <i class="el-icon-plus"></i>
                                <input type="file"
                                accept="video/mp4, video/ogg, video/flv, video/avi, video/wmv, video/rmvb, video/mov"
                                @change="toUploadVideo($event,2)"
                                />
                            </div>
                        </div>
                    </el-form-item>
               </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisibleReta = false">取 消</el-button>
                <el-button type="primary" @click="toAddRetaConfirm">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
export default {
    data(){
        return{
            text:'处理订单',
            page:1,
            pagesize:10,
            total:0,

            form:{
				realname:'',
				phone:'',
				remark:'',
				estate:'',//小区
				house_type:'',//户型
				house_area:'',//面积
				address:'',
				contract_price:'',//合同金额
				deposit_price:'', //定金金额
                balance_price:'',//尾款
				director:[],//负责人
				province:'',
				city:'',
				district:'',
                street:'',
				province_id:'',
				city_id:'',
				district_id:'',
                street_id:''
			},

            province:[],
			city:[],
			district:[],
            street:[],
			provinceObj:{},
			cityObj:{},
			districtObj:{},
            streetObj:{},
            myHeaders: {
              'access-token': this.$store.state.token  , //这里重新定义了请求头
              'Authorization': this.$store.state.token ,
              'user-id':this.$store.state.user_id
            },
			// 施工合同
            fileList1:[],
            dialogImageUrl1:'',
            dialogVisible1:false,

			// 施工图纸
            fileList:[],
            dialogImageUrl:'',
            dialogVisible:false,
            
			// 设计图纸
            fileList_desgin:[],
            dialogImageUrl_desgin:'',
            dialogVisible_desgin:false,
            
			// 选材单
            fileList_mater:[],
            dialogImageUrl_mater:'',
            dialogVisible_mater:false,

			order_id:null, //订单id
			house_keeper:{//管家
				name:'',
				phone:''
			},
			foreman:{//工长
				name:'',
				phone:''
			},
			constrTime:[],//施工时间
			personList:[],//负责人列表
			dialogTableVisible:false, //员工选择对话框
			positionType:1,//1选择管家，2选择工长

            // tabs
            activeName:'1',
            progressData:[], //施工进度列表数据
            dialogVisible_broad:false, //施工播报对话框

            broadListData:[], //播报列表
            broadTitle:'', //播报说明
            broadId:null, //播报id
            page_broad:1,
            pagesize_broad:10,
            // 施工播报图片
            fileListBroad:[],//图片
            fileBroadVideo:[],//视频
            radioBroad:'0', //施工播报类型
            dialogImageUrlBroad:'',
            dialogVisibleBroad:false,

            dialogVisibleArchive:false,//档案目录对话框
            archiveTitle:'',//档案名
            archivesList:[],//档案目录列表
            archiveId:null,//档案目录id
            activeColl:null,//目录选择
            retaList:[], //档案留存列表
            page_reta:1,
            pagesize_reta:10,

            dialogVisibleReta:false,//档案留存对话框
            retaTitle:'',//留存标题
            retaId:null, //留存id
            retaContent:'',//留存内容
            fileListReta:[],//留存文件(图片)
            radioType:'0', //留存类型
            dialogImageUrlReta:'',
            dialogVisibleReta_img:false,
            fileListVideo:[],//留存文件(视频)
            videoFlag:false,

            broadImgList:[],
            retaImgList:[]
        }
    },
    mounted(){
        this.order_id = this.$route.query.order_id;
		this.getProvince()
        if(this.order_id){
            this.text = '订单详情'
            this.getOrderInfo()
        }
        
        
    },
    computed:{
        radio_broad(){
            if(this.broadId){
                return true
            }else{
                return false
            }
        },
        radio_reta(){
            if(this.retaId){
                return true
            }else{
                return false
            }
        }
    },
    methods:{

        // 获取订单详情
        getOrderInfo(){
            this.fileList1 = []
            this.fileList = []
            this.fileList_mater = []
            this.fileList_desgin = []
            let role = localStorage.getItem('role');
            let url = role=='decoration'?'/api/admin/decoration/BuildOrder/view':'/api/admin/builder/BuilderTeamOrder/view';
            this.$http.post(url,{id:this.order_id}).then(res=>{
                console.log(res,'订单详情');
                if(res.code==1){
                    this.form = res.data?res.data:{}
					let startTime = res.data.build_start_time?res.data.build_start_time:'';
					let endTime = res.data.build_end_time?res.data.build_end_time:'';
					this.constrTime = [this.$moment(startTime*1000).format('yyyy-MM-DD'),this.$moment(endTime*1000).format('yyyy-MM-DD')]
					console.log(this.constrTime);
                    let directorArr = JSON.parse(JSON.stringify(res.data.director))
                    console.log(directorArr,'0000');

					// if(res.data.director.length){
                    //     this.house_keeper = directorArr[0]
					//     this.foreman = directorArr[1]
                    // }
                    this.getBuilderList()

				   	this.provinceObj = {
                        cityid:res.data.province_id,
                        city_name:res.data.province
                    };
                    if(res.data.province_id){
                        this.getCityList()
                    }
                    this.cityObj = {
                        cityid:res.data.city_id,
                        city_name:res.data.city
                    };
                    if(res.data.city_id){
                        this.getAreaList()
                    }
                    this.districtObj = {
                        cityid:res.data.district_id,
                        city_name:res.data.district
                    };
                    if(res.data.district_id){
                        this.getStreetList()
                    }
                    this.streetObj = {
                        cityid:res.data.street_id,
                        city_name:res.data.street
                    };

					// 合同
                    if(Array.isArray(res.data.contract_thumb_url)){
                        res.data.contract_thumb_url.map(item=>{
                            this.fileList1.push({
                                id:item.id,
                                url:item.path
                            })
                        })
                    }else{
                        this.fileList1.push({
                            id:res.data.contract_thumb_url.id,
                            url:res.data.contract_thumb_url.path
                        })
                    }

					// 图纸
					if(Array.isArray(res.data.draw_thumb_url)){
                        res.data.draw_thumb_url.map(item=>{
                            this.fileList.push({
                                id:item.id,
                                url:item.path
                            })
                        })
                    }else{
                        this.fileList.push({
                            id:res.data.draw_thumb_url.id,
                            url:res.data.draw_thumb_url.path
                        })
                    }

					// 设计图纸
					if(Array.isArray(res.data.design_thumb_url)){
                        res.data.design_thumb_url.map(item=>{
                            this.fileList_desgin.push({
                                id:item.id,
                                url:item.path
                            })
                        })
                    }else{
                        this.fileList_desgin.push({
                            id:res.data.design_thumb_url.id,
                            url:res.data.design_thumb_url.path
                        })
                    }

					// 选材单
					if(Array.isArray(res.data.material_thumb_url)){
                        res.data.material_thumb_url.map(item=>{
                            this.fileList_mater.push({
                                id:item.id,
                                url:item.path
                            })
                        })
                    }else{
                        this.fileList_mater.push({
                            id:res.data.material_thumb_url.id,
                            url:res.data.material_thumb_url.path
                        })
                    }

					// 处理数据按顺序进行收款
					this.form.pay_progress.map((item,index)=>{
						item.checked = false
						if(this.form.pay_progress[0].pay_status==0){
							this.form.pay_progress[0].checked = true
						}else if(index!=0 && this.form.pay_progress[index-1].pay_status!=0 && this.form.pay_progress[index].pay_status==0){
							this.form.pay_progress[index].checked = true
						}
					})

                }
            })
        },

        // 发起收款按钮
        toCollect(id,status){
            if(status==0){
                this.$http.post('/api/admin/builder/BuilderTeamOrder/initiateCollection',{id}).then(res=>{
                    console.log(res,'发起收款')
                    if(res.code==1){
                        this.$message.success('发起收款成功')
                        this.getOrderInfo()
                    }else{
                        this.$message.warning(res.msg)
                    }
                })
            }
        },
        // 
        getBuilderList(){
            this.$http.post('/api/admin/builder/BuildDirector/index',{order_id:this.order_id}).then(res=>{
                console.log(res,'施工员列表');
                if(res.code==1){
                    this.house_keeper = res.data.list
                    res.data.list.map(item=>{
                        if(item.position==1){
                            this.house_keeper = item
                        }else{
                            this.foreman = item
                        }
                    })
                    console.log(this.house_keeper,this.foreman,'======');
                }
            })
        },

		// 选择管家
		selectKeeper(){
			this.dialogTableVisible = true
			this.positionType = 1
			this.getPersonCharge()
            this.getBuilderList()
		},

		// 选择工长
		selectForeman(){
			this.dialogTableVisible = true
			this.positionType = 2
			this.getPersonCharge()
            this.getBuilderList()
		},

		//对话框选择
		toSelect(index,row){
			console.log(index,row,'对话框选择');
            let oldId = null
            let personId = null
            console.log(this.house_keeper);
            if(this.positionType==1){
                oldId = this.house_keeper.builder_id
                personId = this.house_keeper.id
                if(row.id==this.house_keeper.builder_id){
                    this.dialogTableVisible = false
                    return false
                }
                if(row.id==this.foreman.builder_id){
                    this.$message.warning('不可多职位')
                    return false
                }
            }else{
                oldId = this.foreman.builder_id
                personId = this.foreman.id
                if(row.id==this.foreman.builder_id){
                    this.dialogTableVisible = false
                    return false
                }
                if(row.id==this.house_keeper.builder_id){
                    this.$message.warning('不可多职位')
                    return false
                }
            }
            console.log(oldId,'旧负责人id');
            let params = {
                id:personId,
                order_id:this.order_id,
                builder_id:row.id,
                position:this.positionType,
                old_builder_id:oldId
            }
            this.$http.post('/api/admin/builder/BuildDirector/replace',params).then(res=>{
                console.log(res,'更换结果');
                if(res.code==1){
                    this.$message.success('更换成功')
                    this.getBuilderList()
			        this.dialogTableVisible = false
                }else{
                    this.$message.warning(res.msg)
                }
            })
		},

		// 获取成员列表
		getPersonCharge(){
            let role = localStorage.getItem('role');
			let sid = localStorage.getItem('sid')
            let key = role=='decoration'?'decoration_id':'team_id';
            let params = {
                [`${key}`]:sid
            }
            let url = role=='decoration'?'/api/admin/decoration/Builder/index':'/api/admin/builder/Builder/index';
			this.$http.post(url,params).then(res=>{
				console.log(res,'负责人列表');
				if(res.code==1){
					this.personList = res.data.list?res.data.list:[]
				}
			})
            // this.$http.post('/api/admin/builder/BuildDirector/index',{order_id:this.order_id}).then(res=>{
            //     console.log(res,'负责人列表');
			// 	if(res.code==1){
			// 		this.personList = res.data.list?res.data.list:[]
			// 	}
            // })
		},

        // 施工进度列表
        progressList(){
            let params = {
                order_id:this.order_id,
                page:this.page,
                pagesize:this.pagesize
            }
            this.$http.post('/api/admin/builder/BuildProgress/index',params).then(res=>{
                console.log(res,'施工进度列表');
                if(res.code==1){
                    this.progressData = res.data.list?res.data.list:[];
                    this.total = res.data.total
                }
            })
        },
        // 施工完成时间
        completeTimeFn(row, column, cellValue, index){
            if(cellValue){
                return this.$moment(cellValue*1000).format('YYYY-MM-DD HH:mm')
            }else{
                return
            }
            
        },
        // 进度状态
        progressStatus(row, column, cellValue, index){
            if(cellValue==0){
                return '未完工'
            }else if(cellValue==1){
                return '待确认'
            }else{
                return '已完工'
            }
        },
        // 确认完工按钮
        toConfirm(index,row){
            console.log(index,row,'确认完工按钮');
            // let text = row.status==0?'是否确认已完工？':'是否确认撤回？'
            this.$confirm('确认完成后，状态将不可再更改','提示',{
                confirmButtonText:'确定',
                cancelButtonText:'取消',
                type:'warning'
            }).then(()=>{
                let params = {
                    id:row.id,
                    status:row.status==0?1:0
                }
                this.$http.post('/api/admin/builder/BuildProgress/changeStatus',params).then(res=>{
                    console.log(res,'确认完工结果');
                    if(res.code==1){
                        this.$message.success(row.status==0?'已确认完工':'已撤回')
                        this.progressList()
                    }else{
                        this.$message.warning(res.msg)
                    }
                })
            }).catch(()=>{})
        },



        // 添加播报按钮
        toAddBroad(){
            this.dialogVisible_broad = true
        },
        // 获取播报列表
        getBroadList(){
            let params = {
                order_id:this.order_id,
                page:this.page_broad,
                pagesize:this.pagesize_broad
            }
            this.$http.post('/api/admin/builder/BuildBroadcast/index',params).then(res=>{
                console.log(res,'播报列表');
                if(res.code==1){
                    this.broadListData = res.data.list
                    // 图片预览
                    res.data.list.map(item=>{
                        if(item.type==0){
                            item.media.map(item1=>{
                                this.broadImgList.push(item1.path)
                            })
                        }
                    })
                }
            })
        },
        // 播报删除
        delBroad(id){
            this.$confirm('确定要删除此播报吗?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(()=>{
                this.$http.post('/api/admin/builder/BuildBroadcast/del',{id}).then(res=>{
                    console.log(res,'删除结果');
                    if(res.code==1){
                        this.$message.success('删除成功')
                        this.getBroadList()
                    }else{
                        this.$message.warning(res.msg)
                    }
                })
            })
        },
        // 关闭播报对画框结束的回调
        closedFn(){
            this.broadTitle = ''
            this.broadId = null
            this.radioBroad = '0'
            this.fileListBroad = []
            this.fileBroadVideo = []
        },
        // 编辑播报按钮 打开对话框
        editBroad(id){
            this.$http.post('/api/admin/builder/BuildBroadcast/view',{id}).then(res=>{
                console.log(res,'播报详情');
                if(res.code==1){
                    this.dialogVisible_broad = true
                    this.broadTitle = res.data.title
                    this.broadId = id
                    this.radioBroad = res.data.type==0?'0':'1';
                    if(res.data.type==0){
                        if(Array.isArray(res.data.media)){
                            res.data.media.map(item=>{
                                 this.fileListBroad.push({
                                    url:item.path,
                                    id:item.id
                                 })
                            })
                        }else{
                            this.fileListBroad.push({
                                url:res.data.media.path,
                                id:res.data.media.id
                            })
                        }
                    }else{
                          if(Array.isArray(res.data.media)){
                            res.data.media.map(item=>{
                                 this.fileBroadVideo.push({
                                    url:item.path,
                                    id:item.id
                                 })
                            })
                        }else{
                            this.fileBroadVideo.push({
                                url:res.data.media.path,
                                id:res.data.media.id
                            })
                        }
                    }
                }
            })
        },
        // 添加或编辑播报弹框确定
        toAddBroadConfirm(){
            let broadImg = []
            if(this.radioBroad=='0'){
                this.fileListBroad.map(item=>{
                    if(item.response){
                        broadImg.push(item.response.data.id)
                    }else{
                        broadImg.push(item.id)
                    }
                })
            }else{
                this.fileBroadVideo.map(item=>{
                    broadImg.push(item.id)
                })
            }
            let params = {
                id:this.broadId,
                order_id:this.order_id,
                title:this.broadTitle,
                media:broadImg.join(','),
                type:this.radioBroad
            }
            console.log(params,'播报添加数据');
            let url = this.broadId?'/api/admin/builder/BuildBroadcast/edit':'/api/admin/builder/BuildBroadcast/add';
            this.$http.post(url,params).then(res=>{
                console.log('播报添加结果');
                if(res.code==1){
                    this.$message.success(this.broadId?'修改成功':'添加成功')
                    this.broadTitle='';
                    this.fileListBroad=[];
                    this.dialogVisible_broad=false
                    this.getBroadList()
                }else{
                    this.$message.warning(res.msg)
                }
            })
        },

        // 档案目录列表
        getArchivesList(){
            this.$http.post('/api/admin/builder/ArchiveCategory/index',{order_id:this.order_id}).then(res=>{
                console.log(res,'档案目录列表');
                if(res.code==1){
                    this.archivesList = res.data.list?res.data.list:[]
                }
            })
        },

        // 添加档案目录
        toAddArchive(){
            this.dialogVisibleArchive = true
        },
        // 档案目录对话框关闭回调
        closedArchiveFn(){
            this.archiveTitle = ''
            this.archiveId = null
        },
        
        // 删除档案目录
        delArchive(id){
            this.$confirm('确定删除该目录吗？','提示',{
                confirmButtonText:'确定',
                cancelButtonText:'取消',
                type:'warning'
            }).then(()=>{
                this.$http.post('/api/admin/builder/ArchiveCategory/del',{id}).then(res=>{
                    console.log(res,'删除结果');
                    if(res.code==1){
                        this.$message.success('删除成功')
                        this.getArchivesList()
                    }else{
                        this.$message.warning(res.msg)
                    }
                })
            }).catch(()=>{})
        },
        // 编辑档案目录
        editArchive(name,id){
            this.archiveId = id
            this.archiveTitle = name
            this.dialogVisibleArchive = true
        },
        
        // 添加档案目录对话框确定
        toAddArchiveConfirm(){
            if(this.archiveTitle==''){
                this.$message.warning('请输入档案名')
                return
            }
            let params = {
                order_id:this.order_id,
                id:this.archiveId,
                name:this.archiveTitle
            }
            let url = this.archiveId?'/api/admin/builder/ArchiveCategory/edit':'/api/admin/builder/ArchiveCategory/add';
            this.$http.post(url,params).then(res=>{
                console.log(res,'添加或编辑结果');
                if(res.code==1){
                    this.$message.success(this.archiveId?'修改成功':'添加成功')
                    this.getArchivesList()
                    this.dialogVisibleArchive = false
                }else{
                    this.$message.warning(res.msg)
                }
            })
        },

        // 点击了目录
        changeCollapse(e){
            console.log(e,'目录');
            if(e){
                this.getRetaList(e)
            }
        },

        // 获取档案留存列表
        getRetaList(id){
            let params = {
                category_id:id,
                page:this.page_reta,
                pagesize:this.pagesize_reta
            }
            this.$http.post('/api/admin/builder/BuildArchive/index',params).then(res=>{
                console.log(res,'档案留存列表');
                if(res.code==1){
                    this.retaList = res.data.list?res.data.list:[]
                    res.data.list.map(item=>{
                        if(item.type==0){
                            item.media.map(item1=>{
                                this.retaImgList.push(item1.path)
                            })
                        }
                    })
                }
            })
        },
        
        // 留存对话框关闭回调
        closedRetaFn(){
            this.fileListReta=[]
            this.fileListVideo=[]
            this.retaTitle =''
            this.retaContent = ''
            this.archiveId = null
            this.retaId = null
            this.radioType='0'
        },
        
        // 新增留存按钮
        addReta(id){
            this.archiveId = id
            this.dialogVisibleReta = true
        },
        // 删除留存按钮
        delReta(archiveId,id){
            this.$confirm('确定要删除该项吗？','提示',{
                confirmButtonText:'确定',
                cancelButtonText:'取消',
                type:'warning'
            }).then(()=>{
                this.$http.post('/api/admin/builder/BuildArchive/del',{id}).then(res=>{
                    console.log(res,'删除结果');
                    if(res.code==1){
                        this.getRetaList(archiveId)
                        this.$message.success('删除成功')
                    }else{
                        this.$message.warning(res.msg)
                    }
                })
            })
        },

        // 编辑留存按钮
        editReta(archiveId,id){
            this.archiveId = archiveId
            this.retaId = id
            this.dialogVisibleReta = true
            this.$http.post('/api/admin/builder/BuildArchive/view',{id}).then(res=>{
                console.log(res,'留存详情');
                if(res.code==1){
                    this.retaTitle = res.data.title
                    this.retaContent = res.data.content
                    this.radioType = res.data.type==0?'0':'1'
                    if(res.data.type==0){
                        if(Array.isArray(res.data.media)){
                            res.data.media.map(item=>{
                                 this.fileListReta.push({
                                    url:item.path,
                                    id:item.id
                                 })
                            })
                        }else{
                            this.fileListReta.push({
                                url:res.data.media.path,
                                id:res.data.media.id
                            })
                        }
                    }else{
                          if(Array.isArray(res.data.media)){
                            res.data.media.map(item=>{
                                 this.fileListVideo.push({
                                    url:item.path,
                                    id:item.id
                                 })
                            })
                        }else{
                            this.fileListVideo.push({
                                url:res.data.media.path,
                                id:res.data.media.id
                            })
                        }
                    }
                }
            })
        },

        // 新增或编辑留存对话框确定
        toAddRetaConfirm(){
            let mediaId = []
            if(this.radioType=='0'){
                this.fileListReta.map(item=>{
                    if(item.response){
                        mediaId.push(item.response.data.id)
                    }else{
                        mediaId.push(item.id)
                    }
                })
            }else{
                this.fileListVideo.map(item=>{
                    mediaId.push(item.id)
                })
            }
            let params = {
                order_id:this.order_id,
                category_id:this.archiveId,
                id:this.retaId,
                title:this.retaTitle,
                content:this.retaContent,
                type:this.radioType,
                media:mediaId.join(',')
            }
            console.log(params,'添加留存数据');
            let url = this.retaId?'/api/admin/builder/BuildArchive/edit':'/api/admin/builder/BuildArchive/add';
            this.$http.post(url,params).then(res=>{
                console.log(res,'添加留存结果');
                if(res.code==1){
                    this.getRetaList(this.archiveId)
                    this.$message.success(this.retaId?'修改成功':'添加成功')
                    this.dialogVisibleReta = false
                }else{
                    this.$message.warning(res.msg)
                }
            })
        },

        


        // tabs选中
        handleClick(e){
            console.log(e,'tabs');
            if(e.name=='2'){
                this.progressList()
            }
            if(e.name=='3'){
                this.getBroadList()
            }
            if(e.name=='4'){
                this.getArchivesList()
            }
        },

		// 施工合同
        handleRemove1(file, fileList) {
            this.fileList1 = fileList
        },
        handlePictureCardPreview1(file) {
            this.dialogImageUrl1 = file.url;
            this.dialogVisible1 = true;
        },
        handleEstateSuccess1(res,file,fileList) {
            this.fileList1 = fileList
        },
        beforeAvatarUpload1(file) {
            const isLt2M = file.size / 1024 / 1024 < 2;
            if (!isLt2M) {
                this.$message.error('上传图片大小不能超过 2MB!');
            }
            return isLt2M;
        },

		// 施工图纸
        handleRemove(file, fileList) {
            this.fileList = fileList
        },
        handlePictureCardPreview(file) {
            this.dialogImageUrl = file.url;
            this.dialogVisible = true;
        },
        handleEstateSuccess(res,file,fileList) {
            this.fileList = fileList
        },
        beforeAvatarUpload(file) {
            const isLt2M = file.size / 1024 / 1024 < 2;
            if (!isLt2M) {
                this.$message.error('上传图片大小不能超过 2MB!');
            }
            return isLt2M;
        },

		// 设计图纸
        handleRemove_desgin(file, fileList) {
            this.fileList_desgin = fileList
        },
        handlePictureCardPreview_desgin(file) {
            this.dialogImageUrl_desgin = file.url;
            this.dialogVisible_desgin = true;
        },
        handleEstateSuccess_desgin(res,file,fileList) {
            this.fileList_desgin = fileList
        },
        beforeAvatarUpload_desgin(file) {
            const isLt2M = file.size / 1024 / 1024 < 2;
            if (!isLt2M) {
                this.$message.error('上传图片大小不能超过 2MB!');
            }
            return isLt2M;
        },

		// 选材单
        handleRemove_mater(file, fileList) {
            this.fileList_mater = fileList
        },
        handlePictureCardPreview_mater(file) {
            this.dialogImageUrl_mater = file.url;
            this.dialogVisible_mater = true;
        },
        handleEstateSuccess_mater(res,file,fileList) {
            this.fileList_mater = fileList
        },
        beforeAvatarUpload_mater(file) {
            const isLt2M = file.size / 1024 / 1024 < 2;
            if (!isLt2M) {
                this.$message.error('上传图片大小不能超过 2MB!');
            }
            return isLt2M;
        },

        
		// 施工播报
        handleBroadRemove(file, fileList) {
            this.fileListBroad = fileList
        },
        handleBroadPreview(file) {
            this.dialogImageUrlBroad = file.url;
            this.dialogVisibleBroad = true;
        },
        handleBroadSuccess(res,file,fileList) {
            this.fileListBroad = fileList
        },
        beforeBroadUpload(file) {
            const isLt2M = file.size / 1024 / 1024 < 2;
            if (!isLt2M) {
                this.$message.error('上传图片大小不能超过 2MB!');
            }
            return isLt2M;
        },

        
		// 档案留存()
        handleRetaRemove(file, fileList) {
            this.fileListReta = fileList
        },
        handleRetaPreview(file) {
            this.dialogImageUrlReta = file.url;
            this.dialogVisibleReta = true;
        },
        handleRetaSuccess(res,file,fileList) {
            this.fileListReta = fileList
        },
        beforeRetaUpload(file) {
            const isLt2M = file.size / 1024 / 1024 < 2;
            if (!isLt2M) {
                this.$message.error('上传商品图片大小不能超过 2MB!');
            }
            return isLt2M;
        },

        // 删除播报视频
        toDelBroadVideo(index){
            this.fileBroadVideo.splice(index,1)
        },
        
        // 删除留存视频
        toDelVideo(index){
            this.fileListVideo.splice(index,1)
            console.log(this.fileListVideo);
        },
        // 上传视频
        toUploadVideo(event,type){
            let file = event.target.files[0];
            console.log(file,'视频');
            if (['video/mp4', 'video/ogg', 'video/flv', 'video/avi', 'video/wmv', 'video/rmvb', 'video/mov'].indexOf(file.type) === -1) {
                this.$message.warning('请上传正确的视频格式')
                return false
            }
            let isLtSize = file.size / 1024 / 1024 < 30;
            if (!isLtSize) {
                this.$message.warning("上传视频不能超过 30MB!");
                return;
            }
            let form = new FormData();
            form.append("file", file);
            this.$http
            .post("/api/client/base/uploadfile", form)
            .then(res => {
                console.log(res);
                if (res.code == 1) {
                    let obj = {
                        url:res.data.url,
                        id:res.data.id
                    }
                    // this.back_img = res.data.url;
                    // this.form.back_img = res.data.id;
                    console.log(obj);
                    if(type==1){ //播报
                        this.fileBroadVideo.push(obj)
                    }else{ //留存
                        this.fileListVideo.push(obj)
                    }
                    this.$message.success('上传成功')
                }
            })
            .catch(err => {
                this.$message.warning('上传失败')
            });
        },


        // 省份选择
        select1(){
            this.cityObj={}
            this.districtObj={}
            this.streetObj={}
            this.getCityList()
        },
        // 城市选择
        select2(){
            this.districtObj={}
            this.streetObj={}
            if(!this.provinceObj){
                this.$message.warning('请先选择省份')
                return
            }
            this.getAreaList()
        },
        // 县区选择
        select3(){
            this.streetObj={}
            if(!this.cityObj){
                this.$message.warning('请先选择城市')
                return
            }
            this.getStreetList()
        },
        // 街道选择
        select4(){
            if(!this.districtObj){
                this.$message.warning('请先选择县区')
                return
            }
        },
        
        // 获取省份
        getProvince(){
            this.$http.post('/api/admin/base/Region/getProvinceList').then(res=>{
                console.log(res,'省份');
                if(res.code==1){
                    this.province = res.data?res.data:[]
                }
            })
        },
        // 获取城市
        getCityList(){
            this.$http.post('/api/admin/base/Region/getCityList',{province_id:this.provinceObj.cityid}).then(res=>{
                console.log(res,'城市列表');
                if(res.code==1){
                    this.city = res.data?res.data:[]
                }
            })
        },
        // 获取县区
        getAreaList(){
            this.$http.post('/api/admin/base/Region/getDistrictList',{city_id:this.cityObj.cityid}).then(res=>{
                console.log(res,'县区列表');
                if(res.code==1){
                    this.district = res.data?res.data:[]
                }
            })
        },
        // 获取街道
        getStreetList(){
            this.$http.post('/api/admin/base/region/getStreetList',{district_id:this.districtObj.cityid}).then(res=>{
                console.log(res,'街道列表');
                if(res.code==1){
                    this.street = res.data?res.data:[]
                }
            })
        },

        // 提交按钮
        toSubmit(){
			// let position = [{builder_id:this.house_keeper.id,position:1},{builder_id:this.foreman.id,position:2}]
			// position = JSON.stringify(position)
			let startTime = this.$moment(this.constrTime[0]).format('yyyy-MM-DD')
			let endTime = this.$moment(this.constrTime[1]).format('yyyy-MM-DD')
			console.log(startTime);
			this.form.build_start_time = startTime;
			this.form.build_end_time = endTime;

			this.form.director = '';
			this.form.province = this.provinceObj.city_name;
			this.form.city = this.cityObj.city_name;
			this.form.district = this.districtObj.city_name;
            this.form.street = this.streetObj.city_name;
			this.form.province_id = this.provinceObj.cityid;
			this.form.city_id = this.cityObj.cityid;
			this.form.district_id = this.districtObj.cityid;
			this.form.street_id = this.streetObj.cityid;
			
			// 施工合同
			let contract = []
			this.fileList1.map(item=>{
				if(item.response){
					contract.push(item.response.data.id)
				}else{
					contract.push(item.id)
				}
			})
			// 施工图纸
			let drawing = []
			this.fileList.map(item=>{
				if(item.response){
					drawing.push(item.response.data.id)
				}else{
					drawing.push(item.id)
				}
			})
			// 设计图纸
			let desgin = []
			this.fileList_desgin.map(item=>{
				if(item.response){
					desgin.push(item.response.data.id)
				}else{
					desgin.push(item.id)
				}
			})
			// 选材单
			let mater = []
			this.fileList_mater.map(item=>{
				if(item.response){
					mater.push(item.response.data.id)
				}else{
					mater.push(item.id)
				}
			})
			this.form.contract_thumb_url = contract.join(',')
			this.form.draw_thumb_url = drawing.join(',')
            this.form.material_thumb_url = mater.join(',')
            this.form.design_thumb_url = desgin.join(',')
			console.log(this.form,'编辑提交数据');
			this.$http.post('/api/admin/builder/BuilderTeamOrder/edit',this.form).then(res=>{
				console.log(res,'编辑结果');
				if(res.code==1){
					this.$message.success('修改成功')
					this.$router.back(1)
				}else{
					this.$message.warning(res.msg)
				}
			})
        },

        // 分页
        handleSizeChange(e){
            console.log(e,'[1111');
            this.pagesize = e
            this.progressList()
        },
        handleCurrentChange(e){
            console.log(e,'2222');
            this.page = e
            this.progressList()
        },

        // 返回
        toBack(){
            this.$router.back(1)
        },
    }
}
</script>

<style lang="less">
    @import 'detail.less';
</style>


